FILE(GLOB WIIC_SOURCES "*.c")

IF(APPLE)
	FOREACH(WIIC_SOURCE ${WIIC_SOURCES})
		STRING(REGEX REPLACE ".io_nix.c" "" WIIC_SOURCE ${WIIC_SOURCE})
		SET(WIIC_MAC_SOURCES ${WIIC_MAC_SOURCES} "${WIIC_SOURCE}")
	ENDFOREACH(WIIC_SOURCE)
	SET(WIIC_MAC_SOURCES ${WIIC_MAC_SOURCES} "io_mac.m")
	SET(WIIC_SOURCES ${WIIC_MAC_SOURCES})
ENDIF(APPLE)

ADD_LIBRARY(wiic SHARED ${WIIC_SOURCES})
IF(LINUX)
	TARGET_LINK_LIBRARIES(wiic bluetooth m pthread)
ENDIF(LINUX)
IF(APPLE)
	TARGET_LINK_LIBRARIES(wiic "-framework IOBluetooth -framework Foundation -framework CoreFoundation")
ENDIF(APPLE)

INSTALL(TARGETS	wiic DESTINATION /usr/local/lib)
INSTALL(FILES wiic.h DESTINATION /usr/local/include/wiic)
INSTALL(FILES wiic_functions.h DESTINATION /usr/local/include/wiic)
INSTALL(FILES wiic_macros.h DESTINATION /usr/local/include/wiic)
INSTALL(FILES wiic_structs.h DESTINATION /usr/local/include/wiic)
